<template>
	<view>
		<cu-custom bgColor="bg-gradual-green" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">登录</block>
		</cu-custom>
		<view class="login-img">
			<view class="owl-login" :class="hideEyes?'password':''">
				<view class="hand"></view>
				<view class="hand hand-r"></view>
				<view class="arms">
					<view class="arm"></view>
					<view class="arm arm-r"></view>
				</view>
			</view>
		</view>
		<view class="login-form">
			<text class="text-orange text-bold  text-lg flex justify-center" style="font-size: 38rpx;">南 风 怡 人</text>
			<form >
				<view class="form-input ">
					<input type="text" value="" placeholder="用户名"  style="margin-top: 30rpx;" v-model="loginData.username"/>
				</view>
				<view class="form-input">
					<input type="password" value="" placeholder="密码" @focus="passwordF_B" @blur="passwordF_B" v-model="loginData.password" />
				</view>
				<button class="bg-gradual-green" form-type="submit" @click="login()">登录</button>
			</form>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hideEyes: false,
				loginData:{
					username:undefined,
					password:undefined
				}
			}
		},
		methods: {
			passwordF_B() {
				this.hideEyes = !this.hideEyes;
			},
			login(){
				this.$u.api.appLogin(this.loginData).then(res=>{
					uni.showToast({ icon: 'none',duration: 2000,position: 'bottom',title: '登录成功'});
					let user = res.data.userInfo;
					this.$u.vuex('vuex_user.userId', user.userId);
					this.$u.vuex('vuex_user.username', user.userName);
					this.$u.vuex('vuex_user.avatar', user.avatar);
					this.$u.vuex('vuex_user.userType', user.userType);
					this.$u.vuex('vuex_token', res.data.token);
					uni.navigateBack()
				})
			}
		}
	}
</script>

<style>
	page{
		background: #fff;
	}
	.login-form {
		margin: -18rpx 20rpx 0 20rpx;
		height: 480rpx;
		background: #007AFF;
		border-radius: 20rpx;
		background-color: #EEEEEE;
		box-shadow: 0 4rpx 20rpx #9B9B9B;
		padding: 20px;
	}

	.form-input input {
		background: #ffffff;
		border-radius: 10rpx;
		height: 80rpx;
		margin: 40rpx 0;
		padding: 0 20rpx;
	}

	.login-img {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 108px;
		margin-top: 100rpx;
	}

	.owl-login {
		width: 211px;
		height: 108px;
		background-image: url('');
		background-repeat: no-repeat;
		background-size: 100%;
		position: absolute;
	}

	.owl-login .hand {
		width: 34px;
		height: 34px;
		-webkit-border-radius: 40px;
		border-radius: 40px;
		background-color: #472d20;
		transform: scaleY(0.6);
		transition: 0.3s ease-out;
		position: absolute;
		left: 14px;
		bottom: -8px;
	}

	.owl-login .hand.hand-r {
		left: 170px;
	}

	.owl-login .arms {
		top: 58px;
		position: absolute;
		width: 100%;
		height: 41px;
		overflow: hidden;
	}

	.owl-login .arms .arm {
		width: 40px;
		height: 65px;
		position: absolute;
		left: 20px;
		top: 40px;
		background-image: url("");
		background-size: 100%;
		transition: 0.3s ease-out;
		transform: rotate(-20deg);
	}

	.owl-login .arms .arm.arm-r {
		transform: rotate(20deg) scaleX(-1);
		left: 158px;
	}

	.owl-login.password .hand {
		transform: translateX(42px) translateY(-15px) scale(0.7);
	}

	.owl-login.password .hand.hand-r {
		transform: translateX(-42px) translateY(-15px) scale(0.7);
	}

	.owl-login.password .arms .arm {
		transform: translateY(-40px) translateX(40px);
	}

	.owl-login.password .arms .arm.arm-r {
		transform: translateY(-40px) translateX(-40px) scaleX(-1);
	}
</style>
